package cn.cheqi.recovery.api.config;

import cn.cheqi.recovery.api.interceptor.ApiInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ApiWebMvcConfiguration implements WebMvcConfigurer {


    @Autowired
    private ApiInterceptor apiInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加一个拦截器，拦截以/api为前缀的uri路径
        registry.addInterceptor(apiInterceptor).addPathPatterns("/api/**")
                .excludePathPatterns("/api/user/login");
    }
}
